vpath %.c ./src
vpath %.h ./src
vpath %.o ./obj

#for running on sonoma
#cpler    = sudo mpicc # for mpi pro
#cpler = sudo pathcc # for serial
#cc mpicc gcc icc g++ icpc sudo mpicc
#lib = -L/opt/acml3.1.0/pathscale64_mp/lib/libacml.a -L/opt/acml3.1.0/pathscale64_mp/lib/libacml_mv.a -lfftw3 -lm
#incl = -I"/opt/acml3.1.0/pathscale64_mp/include/"

#for shemesh
#cpler = sudo pathcc # for serial
#lib = -L/opt/acml4.1.0/pathscale64/lib/libacml.a -L/opt/acml4.1.0/pathscale64/lib/libacml_mv.a -lfftw3 -lm
#incl = -I"/opt/acml4.1.0/pathscale64/include/" 
#cpler = gcc # for serial
#lib = -L/opt/acml4.1.0/gfortran64/lib/libacml.a -L/opt/acml4.1.0/gfortran64/lib/libacml_mv.a -lfftw3 -lm
#incl =-I"/opt/acml4.1.0/gfortran64/include/"

#for shapash
cpler = gcc # for serial
lib = -L/opt/acml4.1.0/pathscale64/lib/libacml.a -L/opt/acml4.1.0/pathscale64/lib/libacml_mv.a -lfftw3 -lm
incl = -I"/opt/acml4.1.0/pathscale64/include/" 
#cpler = gcc # for serial
#lib = -L/opt/acml4.1.0/gfortran64/lib/libacml.a -L/opt/acml4.1.0/gfortran64/lib/libacml_mv.a -lfftw3 -lm
#incl =-I"/opt/acml4.1.0/gfortran64/include/"


#dgk2.chem.utoronto.ca
#cpler = gcc
#lib = -L/opt/acml4.1.0/gfortran64/lib/libacml.a -L/opt/acml4.1.0/gfortran64/lib/libacml_mv.a -lfftw3 -lm
#incl = -I"/opt/acml4.1.0/gfortran64/include/"
#grappa
#cpler = gcc -std=gnu9x
#lib = -L


tag  = -O2 -m64

execute  = xct/yzhou 
execute_gdb = xct_gdb/yzhou

obj_all = $(source_new:src/%.c=obj/%.o)\
          $(source_for:src/%.for=obj/%.o)\
          $(source_old:src/%.c=obj/%.o)

obj_all_gdb  = $(obj_old_gdb) $(obj_new_gdb)
obj_old_gdb  = $(source_old:src/%.c=obj_gdb/%.o)\
               $(source_for:src/%.for=obj_gdb/%.o)
obj_new_gdb  = $(source_new:src/%.c=obj_gdb/%.o)



source_old = 
source_new  = src/chain.c src/correlation.c src/integration.c \
              src/rnruni.c src/chain_spectral.c\
	      src/mytime.c src/chain_expcos.c\
              src/main.c src/chain_ana.c
#              src/main_silent.c
       #       src/main_mpi.c src/mytime_mpi.c
source_for = 

.PHONY     : cl all bk

all        : cl $(execute) #$(execute_gdb)

$(execute)                    : $(obj_all)
	@test -d xct || mkdir xct
	@echo compiling main
	$(cpler) $(tag) $(obj_all) $(lib) -o $(execute)

$(obj_all):obj/%.o            : src/%.c
	@test -d obj || mkdir obj
	$(cpler) $(incl) -c $(tag) $< -o $@

$(execute_gdb)                : $(obj_all_gdb)
	@test -d debug || mkdir debug 
	@echo compiling main
	$(cpler) -ggdb $(obj_all_gdb) $(lib) -o $(execute_gdb)

$(obj_old_gdb):obj_gdb/%.o    : src/%.c
	@test -d obj_gdb || mkdir obj_gdb
	$(cpler) $(incl) -c -O3 $< -o $@

$(obj_new_gdb):obj_gdb/%.o    : src/%.c
	@test -d obj_gdb || mkdir obj_gdb
	$(cpler) $(incl) -c -ggdb $< -o $@

cl                            : 
	-rm -r -f $(execute) $(execute_gdb) $(obj_new_gdb) $(obj_old_gdb)\
	$(obj_all)


